<template>
	<!-- 资金帐户列表 -->
	<div>
    <el-breadcrumb class="breadcrumb" separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>现金结算</el-breadcrumb-item>
    </el-breadcrumb>
		<el-table v-loading='loading' border :data="goodsArr" max-width="900">
			<el-table-column width="50" prop="id" label="序号" show-overflow-tooltip>
			</el-table-column>
			<el-table-column  prop="accountName" label="申请帐号" show-overflow-tooltip>
			</el-table-column>
			<el-table-column prop="applyTime" label="申请时间" show-overflow-tooltip>
			</el-table-column>
			<el-table-column prop="bankName" label="银行名称" show-overflow-tooltip>
			</el-table-column>
			<el-table-column prop="bankCardName" label="银行开户名称" show-overflow-tooltip>
			</el-table-column>
			<el-table-column prop="bankCardNumber" label="银行卡号" show-overflow-tooltip>
			</el-table-column>
			<el-table-column label="申请金额（分）">
                <template slot-scope="scope">
                    <span>{{-scope.row.cashAmount}}</span>
                </template>
			</el-table-column>
			<el-table-column prop="state" label="状态">
				<template slot-scope="scope">
                    <span>{{scope.row.state | moneystate}}</span>
                </template>
			</el-table-column>
			<el-table-column label="操作" width="80px">
				<template slot-scope="scope">
					<el-button v-if="scope.row.state == 'REMIT'" size="small" @click="cancel(scope.row.id)" type="danger">撤消</el-button>
					<el-button v-else size="small" @click="confirm(scope.row.id)" type="success">打款</el-button>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination class="page-num" background layout="prev, pager, next" :page-size="page_size" @current-change="handleCurrentChange" :total="page">
		</el-pagination>
	</div>
</template>
<script>
	export default {
		name: 'manage',
		data() {
			return {
				title:'',
				goodsArr: [],
				params: {
					"numPerPage": 10,			//每页记录数
					"order": "asc",				//排序顺序
					"pageNum": 1,				//当前页数
				},
				page_size: 10, //每页显示几个
				page: 0, //总页数
				currentPage: 1, //当前页`1
				loading:true
			};
		},
		components: {
		},
		created() {

		},
		mounted(){
			this.getList();
		},
		methods: {
			// 确认
			confirm(id){
				this.$confirm('确认是否打款', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$post('confirm',{cashId:id}).then((res)=>{
						if(res.code == 200){
							this.getList();
							this.$message({
								duration: 1000,
								type: 'success',
								message: res.message
							});
						}else{
							this.$message({
								duration: 1000,
								type: 'error',
								message: res.message
							});
						}
					})
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消'
					});
				});
			},
			// 取消
			cancel(id){
				this.$confirm('是否撤消?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$post('cancel',{cashId:id}).then((res)=>{
						if(res.code == 200){
							this.getList();
							this.$message({
								duration: 1000,
								type: 'success',
								message: res.message
							});
						}else{
							this.$message({
								duration: 1000,
								type: 'error',
								message: res.message
							});
						}
					})
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消'
					});
				});
			},
			detail(){
				this.$router.push('capitalDetail')
			},
		// 获取列表
		getList() {
			this.loading = true;
			this.params.pageNum = this.currentPage;
			this.params.orderDate = this.params.orderDate==""?'':this.params.orderDate/1000;
			this.$post("accountList", this.params).then(res => {
				this.loading = false;
				if (res.code == 200) {
					this.goodsArr = [];
					this.page = res.data.total;
					this.goodsArr = res.data.rows;
				} else {
					this.$msg.warning(res.message);
				}
			})
			.catch((e)=>{
				this.loading = false;
			})
		},
		handleCurrentChange(page){
			this.currentPage = page;
			this.getList();
		}
	},
	filters:{
		moneystate(state){
			if(state == "REMIT"){
				return "已打款";
			}else{
				return "未打款";
			}
		}
	}
}
</script>
<style type="text/css">
</style>